
app.controller('detailLoginCtrl', ['$scope', function ($scope) {
	var needNewPagination = true;
	$("#date-1").val(""); $("#date-2").val("");
	lookDetail($("#date-1").val(), $("#date-2").val(), 1);
	
	$("#sel-date").click(function() {
        var startTime = $("#date-1").val();
		var endTime = $("#date-2").val();
		needNewPagination = true;
		lookDetail(startTime, endTime, 1);
    });
	
	function lookDetail(startTime, endTime, pageNo) {		
		var param = {
			startTime: startTime,
			endTime: endTime,
			pageNo: pageNo,
			pageCount: 10,
		};
		AQ.callAQ("getLoginDetail.do", param, function(result) {
			 var data = [];
			for (var i = 1; i < result.length; ++i) {
				data.push(result[i]);
			}
			$scope.$apply(function () {
				$scope.listData = data;
				if(pageNo == 1 && needNewPagination) {	//创建分页
					var num_entries = result[0].count;
					Utils.newPagination("Pagination", num_entries, function(page_index, jq) {
						if(page_index == 0 && needNewPagination) {
							needNewPagination = false;
							return;
						}
						lookDetail($("#date-1").val(), $("#date-2").val(), page_index+1);
					});
				}
			});
		}, function(err, code) {
			Utils.msgDialog(err + "["+ code +"]");
		});
	}

}]);